package com.example.a79273.shandianban.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;

import com.example.a79273.shandianban.config.NetConfigYouRen;
import com.example.a79273.shandianban.model.XianHuoBean;
import com.squareup.picasso.Picasso;

import java.util.List;

/**
 * Created by 79273 on 2016/9/2.
 */
public class XianHuoGridAdapter extends BaseAdapter {

    private List<XianHuoBean.DataBean.ListsBean> mData;
    private Context mContext;
    private Picasso picasso;

    public XianHuoGridAdapter(List<XianHuoBean.DataBean.ListsBean> data, Context context) {
        mData = data;
        mContext = context;
        picasso = Picasso.with(context);
    }

    @Override
    public int getCount() {
        return mData == null ? 0 : mData.size();
    }

    @Override
    public XianHuoBean.DataBean.ListsBean getItem(int position) {
        return mData.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {

        if (convertView == null) {
            convertView = new ImageView(mContext);
        }
        picasso.load(NetConfigYouRen.ROOT_URL+getItem(position).getVsrc()).into((ImageView) convertView);
        return convertView;
    }
}
